package Java8.optional;

import java.util.Optional;

public class OptionalDemoOne {

    public static void main(String[] args) {
        Optional<PrimeMinister> pm = Optional.of(new PrimeMinister());

        String pmName = pm.map(PrimeMinister::getName).orElse("None");
        System.out.println(pmName);
        //Assign Some Value to PrimeMinister.name
        pm = Optional.of(new PrimeMinister("Narendra Modi"));
        pmName = pm.map(PrimeMinister::getName).orElse("None");
        System.out.println(pmName);
    }
}